package com.gamelife.web.exception;

import com.gamelife.web.domain.AjaxResult;
import com.gamelife.web.exception.login.CaptchaExpireException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public AjaxResult handler(Exception e) {
        log.error(e.getMessage(),e);
        return AjaxResult.error();
    }

    @ExceptionHandler(value = BaseException.class)
    public AjaxResult handler(BaseException e) {
        log.error(e.getMessage(),e);
        return AjaxResult.error(e.getCode(),e.getMsg(),null);
    }

    @ExceptionHandler(value = RuntimeException.class)
    public AjaxResult handler(RuntimeException e) {
        log.error(e.getMessage(),e);
        return AjaxResult.error(e.getMessage(),null);
    }





}